package cn.ffcs.uec.salary.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.salary.dao.UecSalaryPayitemDao;
import cn.ffcs.uec.salary.model.UecSalaryPayitem;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecSalaryPayitemDao")
@Transactional
public class UecSalaryPayitemDaoImpl extends BaseDaoImpl implements UecSalaryPayitemDao {

	@Override
	public PageInfo queryPageInfoByUecSalaryPayitem(UecSalaryPayitem uecSalaryPayitem, int current,
			int pageSize) {
		if (null != uecSalaryPayitem) {
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM UEC_SALARY_PAYITEM T WHERE 1 = 1 ");
			List<Object> params = new ArrayList<Object>();
			sb.append(" AND T.STATUS_CD = ? ");
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			
			// 银行账号
			if (uecSalaryPayitem.getBankaccount() != 0) {
				sb.append(" AND T.BANKACCOUNT = ? ");
				params.add(uecSalaryPayitem.getBankaccount());
			}
			
			// 项目分类
			if (!StrUtil.isNullOrEmpty(uecSalaryPayitem.getCategoryId())) {
				sb.append(" AND T.CATEGORY_ID = ? ");
				params.add(uecSalaryPayitem.getCategoryId());
			}
			
			// 薪资年度
			if (!StrUtil.isNullOrEmpty(uecSalaryPayitem.getCyear())) {
				sb.append(" AND T.CYEAR = ? ");
				params.add(uecSalaryPayitem.getCyear());
			}
			
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecSalaryPayitem.class);
		} else {
			return null;
		}
	}
}
